#!/usr/bin/env ruby
## @example example1.rb
#  @see example1.c

$LOAD_PATH << File.expand_path("../../../lib/rubyFulguro/fulguro")


require 'fulguro'
include Fulguro

imin = flgr2d_load_pgm('../../images/gray/lena.pgm')
imout = FLGR_Data2D.new(imin.size_y,imin.size_x,imin.spp,FLGR_UINT8)
imtmp = FLGR_Data2D.new(imin.size_y,imin.size_x,imin.spp,FLGR_UINT8)

scr0 = flgr2d_rtview_create(imin, 1, 2)

flgr2d_rtview_refresh(scr0, imin, 0, 0)
flgr2d_copy(imout,imin)

for i in 1..200
    nhb = FLGR_Data2D.new(i*2+1,i*2+1,imin.spp,FLGR_UINT8,FLGR_RECT,FLGR_8_CONNEX)
    flgr2d_open(imtmp,imout,nhb)
    flgr2d_close(imout,imtmp,nhb);
    flgr2d_rtview_refresh(scr0, imout, 0, 1)
end

flgr2d_save_pgm(imout,"out.pgm")


